function getHash() {
    if (location.href.indexOf("?") != -1) {
        return location.href.split("?")[1]
    } else {
        return ""
    }
}
// 渲染
function loadWindow() {
    let hash = getHash()
    let labels = document.querySelectorAll("#region-select label")
    if (hash == "") {
        hash = "华东华北华南&手机笔记本智能音箱"
        history.pushState({}, "title", "?" + hash)
    } else {
        hash = decodeURIComponent(hash)
        let area = hash.split("&")[0]
        let product = hash.split("&")[1]
        if (area.length == 0) {
            area = "华东华北华南"
        }
        if (product.length == 0) {
            product = "手机笔记本智能音箱"
        }
        history.pushState({}, "title", "?" + area + "&" + product)

        for (let i = 0; i < labels.length; i++) {
            const l = labels[i]
            const s = l.querySelector("input")
            const t = l.querySelector("input").value
            let a = area.indexOf(t) != -1
            let b = product.indexOf(t) != -1
            if (a && !b) {
                s.checked = "true"
            } else if (!a && !b) {
                s.checked = ""
            } else if (!a && b) {
                s.checked = "true"
            }
        }
    }
    let arr = decodeURIComponent(location.href.split("?")[1])
    let area = arr.split("&")[0]
    let product = arr.split("&")[1]
    if (area.length == 6) {
        labels[0].querySelector("input").checked = "true"
    }
    if (product.length == 9) {
        labels[4].querySelector("input").checked = "true"
    }
}
// 判断选中
function getSelectArr() {
    let labels = document.querySelectorAll("#region-select label")
    let str = ""
    let a = ""
    let b = ""
    let area = ["华东", "华北", "华南"]
    let product = ["手机", "笔记本", "智能音箱"]
    for (let i = 0; i < labels.length; i++) {
        const l = labels[i];
        const inp = l.querySelector("input")
        const t = inp.value
        if (t.indexOf("全选") != 0) {
            if (inp.checked) {
                if (area.indexOf(t) != -1) {
                    a += t
                }
                if (product.indexOf(t) != -1) {
                    b += t
                }
            }
        }
    }
    let arr = decodeURIComponent(location.href.split("?")[1])
    let area1 = arr.split("&")[0]
    let product1 = arr.split("&")[1]
    if (area1.length == 6) {
        labels[0].querySelector("input").checked = "true"
    }
    if (product1.length == 9) {
        labels[4].querySelector("input").checked = "true"
    }
    str = "?" + a + "&" + b
    history.pushState({}, "title", str)
    return str
}
// 根据hash渲染
function formhashselect() {
    let arr = decodeURIComponent(location.href.split("?")[1])
    let area = arr.split("&")[0]
    let product = arr.split("&")[1]
    let labels = document.querySelectorAll("#region-select label")
    for (let i = 0; i < labels.length; i++) {
        const l = labels[i];
        const inp = l.querySelector("input")
        const t = inp.value
        const a = area.indexOf(t) != -1
        const b = product.indexOf(t) != -1
        if (a && !b) {
            inp.checked = "true"
        } else if (!a && b) {
            inp.checked = "true"
        } else if (!a && !b) {
            inp.checked = ""
        }
    }
    if (area.length == 6) {
        labels[0].querySelector("input").checked = "true"
    }
    if (product.length == 9) {
        labels[4].querySelector("input").checked = "true"
    }
    let output1 = getData()
    createCharts(output1)
    createTable(output1)
}